package stream;

import java.util.Arrays;

/**
 * @author yangwenqi
 * @decs TODO
 * @date 2025/5/6
 * 问题 4：获取 String 集合中最长的元素
 */
public class Test04 {
    public static void main(String[] args) {
        String[] strings = {"asdg","augdigs","kashdkj","asdfghjkla"};

        String s = Arrays.stream(strings)
                .max((s1, s2) -> Integer.compare(s1.length(), s2.length()))
                .orElse(null);
        System.out.println("最长的字符串：" + s);
    }
}
